import 'package:flutter/material.dart';

class LoginRoute extends StatefulWidget {
  const LoginRoute({super.key});

  @override
  _loginState createState() => _loginState();
}

class _loginState extends State<LoginRoute> {
  final TextEditingController _unameController = TextEditingController();
  final TextEditingController _uPasswordContrller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('欢迎来到xx系统'),
      ),
      body: Column(
        children: <Widget>[
          const Text(
            '欢迎登录xx系统',
            style: TextStyle(fontFamily: 'font_1', fontSize: 24),
          ),
          TextField(
            autofocus: true,
            decoration: const InputDecoration(
                labelText: '账户',
                hintText: '快点输入账户',
                prefixIcon: Icon(Icons.person)),
            controller: _unameController,
          ),
          const TextField(
            autofocus: true,
            decoration: InputDecoration(
                labelText: '密码',
                hintText: '输入密码了',
                prefixIcon: Icon(Icons.lock)),
            obscureText: true,
          ),
          Center(
              child: TextButton.icon(
                  onPressed: () {
                    if (_unameController.text == "whz" ||
                        _uPasswordContrller.text == "123456") {
                      Navigator.pushNamed(context, 'index');
                    }
                  },
                  icon: const Icon(Icons.login),
                  label: const Text('登录')))
        ],
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    _unameController.addListener(() {
      print(_unameController.text);
    });
  }
}
